<html lang="zh">
<head>
<meta charset="utf-8" />
<title>缂栬緫鍗氬</title>
<link type="text/css" rel="stylesheet" href="../css/register.css" />
<link type="text/css" rel="stylesheet" href="../css/code.css" />
<script type="text/javascript" src="../js/blog.js"></script>
</head>
<body>
	<div class="mainbar" style="margin-left: -290px;">
		<div id="nav">
			<div id="nav-top">
				<h3>Servlet杩囨护鍣�/h3>
			</div>
			<div class="nav-list">
				<div class="nav-title">
					<span>Servlet杩囨护鍣�/span>
				</div>
				<pre class="nav-text">
Servlet杩囨护鍣ㄧ敤浜庡Web搴旂敤绋嬪簭鐨勮姹傚拰鍝嶅簲鎵ц缁熶竴鐨勫墠鏈熸垨鍚庢湡杩囨护鎿嶄綔锛屼粠鑰屾嫤鎴姹傚拰鍝嶅簲锛�
鎴栬�瀵硅姹傚拰鍝嶅簲淇℃伅鎵ц蹇呰鐨勪慨鏀规搷浣溿�
</pre>
				<pre class="nav-text">
Servlet杩囨护鍣ㄧ殑瀹炶川鏄湪Filter鐨刣oFilter()鏂规硶涓ServletRequest鍜孲ervletResponse杩�
琛屽鐞嗭紝澶勭悊涔嬪墠浼氳浆鎹负HttpServletRequest鍜孒ttpServletResponse锛岀劧鍚庨�杩嘑ilterChain
鐨刣oFilter()鏂规硶灏嗚姹傚拰鍝嶅簲浼犻�缁橲ervlet鎴栦笅涓�釜杩囨护鍣ㄣ�
</pre>
			</div>
			<div class="nav-list">
				<div class="nav-title">
					<span>Servlet杩囨护鍣�/span>
				</div>
				<pre class="nav-text">
鎵�湁鐨凷ervlet杩囨护鍣ㄧ被閮藉繀椤诲疄鐜癋ilter鎺ュ彛銆�
</pre>
				<pre class="nav-text">
鑷畾涔夌殑Filter濡備笅锛�
</pre>
				<pre class="nav-tab">
<span class="tab-title">灞炴�             鍊�             鎻忚堪</span>
<hr class="tab-sep" />
autoplay	autoplay	闊抽鍦ㄥ氨缁悗椹笂鎾斁
controls	controls	鍚戠敤鎴锋樉绀烘帶浠讹紝姣斿鎾斁鎸夐挳
loop	        loop	        闊抽缁撴潫鏃堕噸鏂板紑濮嬫挱鏀�
preload	        preload	        闊抽鍦ㄩ〉闈㈠姞杞芥椂杩涜鍔犺浇锛屽苟棰勫鎾斁
src	        url	        瑕佹挱鏀剧殑闊抽鐨刄RL
</pre>
				<pre class="nav-java">
<span class="java-pln"><span class="java-kwd">public</span> <span
						class="java-kwd">class</span> GlobalFilter <span class="java-kwd">implements</span> Filter <span
						class="java-pun">{</span> 

    <span class="java-kwd">private</span> FilterConfig config <span
						class="java-pun">=</span> <span class="java-kwd">null</span>; 

    <span class="java-lit">@Override</span> 
    <span class="java-kwd">public</span> <span class="java-kwd">void</span> init<span
						class="java-pun">(</span>FilterConfig config<span class="java-pun">)</span> <span
						class="java-kwd">throws</span> ServletException <span
						class="java-pun">{</span> 
        <span class="java-kwd">this</span>.config <span class="java-pun">=</span> config; 
    <span class="java-pun">}</span> 

    <span class="java-lit">@Override</span> 
    <span class="java-kwd">public</span> <span class="java-kwd">void</span> doFilter<span
						class="java-pun">(</span>ServletRequest req, ServletResponse resp, 
            FilterChain chain<span class="java-pun">)</span> <span
						class="java-kwd">throws</span> IOException, ServletException <span
						class="java-pun">{</span> 
        HttpServletRequest request <span class="java-pun">=</span> <span
						class="java-pun">(</span>HttpServletRequest<span class="java-pun">)</span> req; 
        HttpServletResponse response <span class="java-pun">=</span> <span
						class="java-pun">(</span>HttpServletResponse<span class="java-pun">)</span> resp; 
        <span class="java-com">// 瀵箁equest鍜宺esponse鎵ц杩囨护鍓嶅鐞�/ 瀵箁equest鍜宺esponse鎵ц杩囨护鍓嶅鐞�/ 瀵箁equest鍜宺esponse鎵ц杩囨护鍓嶅鐞�/span> 
        chain.doFilter<span class="java-pun">(</span>req, resp<span
						class="java-pun">)</span>; 
        <span class="java-com">// 瀵箁esponse鎵ц杩囨护鍚庡鐞�/span> 
    <span class="java-pun">}</span> 

    <span class="java-lit">@Override</span> 
    <span class="java-kwd">public</span> <span class="java-kwd">void</span> destroy<span
						class="java-pun">(</span><span class="java-pun">)</span> <span
						class="java-pun">{</span> 
        <span class="java-kwd">this</span>.config <span class="java-pun">=</span> <span
						class="java-kwd">null</span>; 
    <span class="java-pun">}</span> 

<span class="java-pun">}</span></span>
</pre>
			</div>
			<div class="nav-list">
				<div class="nav-title">
					<span>Servlet杩囨护鍣�/span>
				</div>
				<pre class="nav-text">
鍦╳eb.xml涓厤缃甋ervlet杩囨护鍣ㄣ�
</pre>
				<pre class="nav-xml"
					onmouseover="this.style.overflowX='auto';document.getElementById('nav-hidden').style.display='none'"
					onmouseout="this.style.overflowX='hidden';document.getElementById('nav-hidden').style.display=''">
浣犲ソ浣犲ソ浣犲ソ浣犲ソ浣犲ソ浣犲ソ浣犲ソ浣犲ソ浣犲ソ浣犲ソ浣犲ソ浣犲ソ浣犲ソ浣犲ソ浣犲ソ浣犲ソ浣犲ソ浣犲ソ濂戒綘濂戒綘濂戒綘濂藉ソ浣犲ソ浣犲ソ浣犲ソ
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
..........................................................................
22222222222222222222222222222222222222222222222222222222222222222222222222
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAA
A      A
1111
2222
8888
aaaa
iiii
wwww
llll
AAAA
WWWW
----
////
!!!!
{{{{
((((
[[[[
^^^^
<span class="xml-pln"><span class="xml-tag">&lt;filter&gt;</span>
    <span class="xml-tag">&lt;filter-name&gt;</span>GlobalFilter<span
						class="xml-tag">&lt;/filter-name&gt;</span>
    <span class="xml-tag">&lt;filter-class&gt;</span>com.filter.GlobalFilter<span
						class="xml-tag">&lt;/filter-class&gt;</span>
<span class="xml-tag">&lt;/filter&gt;</span>

<span class="xml-tag">&lt;filter-mapping&gt;</span>
    <span class="xml-tag">&lt;filter-name&gt;</span>GlobalFilter<span
						class="xml-tag">&lt;/filter-name&gt;</span>
    <span class="xml-tag">&lt;url-pattern&gt;</span><span
						class="xml-tag">/</span>*<span class="xml-tag">&lt;/url-pattern&gt;</span>
    <span class="xml-tag">&lt;dispatcher&gt;</span>REQUEST<span
						class="xml-tag">&lt;/dispatcher&gt;</span>
<span class="xml-tag">&lt;/filter-mapping&gt;</span></span>
</pre>
				<pre id="nav-hidden" class="nav-hidden">
</pre>
				<pre class="nav-text">
&lt;dispatcher&gt;鍙互閰嶇疆0鍒�涓紝鍙傛暟鍒嗗埆涓篟EQUEST銆両NCLUDE銆丗ORWARD銆丒RROR銆�
REQUEST锛氭嫤鎴敤鎴风殑璇锋眰锛�
INCLUDE锛氭嫤鎴猂equestDispatcher.include()鏂规硶璋冪敤鐨勮祫婧愶紱
FORWARD锛氭嫤鎴猂equestDispatcher.forward()鏂规硶璋冪敤鐨勮祫婧愶紱
ERROR锛氭嫤鎴０鏄庡紡寮傚父澶勭悊鏈哄埗璋冪敤鐨勮祫婧愩�
</pre>
			</div>
		</div>
	</div>
</body>
</html>